/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jl.tools.stkeditor;

import com.jl.tools.stkeditor.exception.DataNotMatchCodingScheamException;
import com.jl.tools.stkeditor.manager.Manager;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author LuHongjun
 */
public class GenTextAndItem implements IModel {

	private List<ResultListenner> listenner = new ArrayList<ResultListenner>();

	public GenTextAndItem() {
	}

	public void generateCode(String data)
			throws DataNotMatchCodingScheamException {
		Manager manager = new Manager();
		manager.patch(data);
		notifyAllResultObserver(manager.getResult());
	}

	private void notifyAllResultObserver(String[] res) {
		for (ResultListenner r : listenner) {
			r.updataResult(res);
		}
	}

	@Override
	public void addObserver(ResultListenner l) {
		listenner.add(l);
	}
}
